<template>
  <div>
    <AplidForm
      ref="formRef"
      v-bind="OtherFormConfig"
      v-model="formModel"
      @submit="onSubmit">
    </AplidForm>
  </div>
</template>

<script setup lang="ts">
import apiMod from '@/apiMod'
import { OtherFormConfig } from '@/views/datacenter/basicData/serviceFacility/config'
// import { useCommonStore } from '@/stores/common'

const emit = defineEmits(['refresh'])
// 接受第二张表拿到的整合数据
const props = defineProps(['extendInfo'])

const formModel = ref({
  dpSenileProductsPOList:[],
  dpFacilityEquipmentPOList:[],
  dpOperateRecordPOList:[]
})
const formRef = ref(null)
const onSubmit = (form, done) => {
  console.log('数据',form)
  form.dpFacilityEquipmentPOList.forEach(el => {
    el.soleValue = props.extendInfo.soleValue,
    el.code=2006
  });
  form.dpSenileProductsPOList.forEach(el => {
    el.soleValue = props.extendInfo.soleValue,
    el.code = 2005
  });
  form.dpOperateRecordPOList.forEach(el=>{
    el.soleValue = props.extendInfo.soleValue,
    el.code = 2013
  })
  done()
  const params = {
      ...form,
      soleValue:props.extendInfo.soleValue,
      code:2004
  }
  console.log('所有数据',params)
  // 发送搜集的采集数据
  apiMod.dpServiceFacilityOther_gatherAll(params).then(res=>{
    emit('refresh',res.data)
    done()
  }).catch(()=>{
    done()
  })
}

const onSave = () => {
  formRef.value!.onSubmit()
}
defineExpose({
  onSave
})
</script>

<style scoped></style>
